﻿using System;
using System.Windows.Data;
using TestBat.Models.Exceptions;

namespace TestBat.Views.Converters
{
    [ValueConversion(typeof(BusinessException), typeof(string))]
    public class BusinessExceptionConverter : IValueConverter
    {
        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return "Message: " + ((BusinessException)value).Message +
                "\nInner message: " + ((BusinessException)value).InnerException.Message + 
                "\nStack trace: " + ((BusinessException)value).StackTrace;
        }
    }
}
